// Copyright: personal possession of Nguyen Minh Kha
// Description: Game class manage Game control, 
//  Game init, Game loop, Game end, Game event...
// Date time: 07/07/2011(mm/dd/yyyy)
// License: free source
// Version: 1.0
// Writer: Nguyen Minh Kha

#include <time.h>
#include <Windows.h>
#include "world.h"

#ifndef GAMEFRAMEWORK_GAME_H_
#define GAMEFRAMEWORK_GAME_H_

// This class is representation for tradition function of window API application
// A warper class for WinProc, RegisterClassEx, InitWindowInstance.
// Example usage:
//     Game gameInstance(hInstance, hPreInstance, lpCmdLine, nCmdShow);
//     int executeResult = gameInstance.Excute();
class Game
{
  //
  // Static
  //
private:
  static LRESULT DummyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  // static instance, use for mapping static DummyWndProc to instance WndProc
  static Game *gameInstance;
  //
  // Constructor, destructor
  //
public:
  Game(void);
  Game(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine,
       int nCmdShow);
  ~Game(void);
  //
  // Method
  //
public:
  int Excute();
  void Pause();
  void Resume();
private:
  // Init Game, load resource, bitmap, Sound, directx...
  int Init();
  // Game run, most of application time spend here
  int Run();
  // Game end, return value to system.
  // returnValue: output, get from Game.Run()
  int End(int returnValue);
  ATOM RegisterWindowClass();
  BOOL InitInstance();

  //
  // Data member
  //

private:
  HINSTANCE hInstance; 
  HINSTANCE hPrevInstance; 
  LPSTR lpCmdLine; 
  int nCmdShow;
  HWND hWnd; // handle main window Game
  int done; // Game done or not
  World world;
  LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, 
                           LPARAM lParam);
  DISALLOW_COPY_AND_ASSIGN(Game); // disable copy operator
};
#endif // GAMEFRAMEWORK_GAME_H_

